package com.blq.api.controller;

import com.alibaba.fastjson.JSONObject;
import com.blq.api.service.ApiService;
import com.blq.common.annotation.RepeatSubmit;
import com.blq.common.constant.Constants;
import com.blq.common.core.domain.PageQuery;
import com.blq.common.core.domain.R;
import com.blq.common.core.domain.entity.SysDept;
import com.blq.common.core.domain.entity.SysUser;
import com.blq.common.core.page.TableDataInfo;
import com.blq.common.utils.ResultMsg;
import com.blq.common.utils.StringUtils;
import com.blq.system.service.ISysUserService;
import com.blq.system.service.SysLoginService;
import com.blq.web.CustomerRepair.domain.CustomerRepair;
import com.blq.web.CustomerRepair.service.impl.CustomerRepairServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 小程序接口嘞
 *
 * @author: Blq <br>
 */
@RestController
@RequestMapping("/api")
public class ApiController {

    @Autowired
    private ApiService apiService;
    @Autowired
    private CustomerRepairServiceImpl customerRepairService;
    @Autowired
    private SysLoginService loginService;
    @Autowired
    private ISysUserService sysUserService;

    /**
     * 根据工单ID查询应收款方
     * @param orderId
     * @return
     */
    @GetMapping("queryPayeeByOrder")
    public ResultMsg queryPayeeByOrder(@RequestParam String orderId) {
        return apiService.queryPayeeByOrder(orderId);
//        return ResultMsg.SELECT_SUCCESS.setNewData(dept);
    }

    /**
     * 功能描述: 〈获取微信手机号〉 <br>
     *
     * @param jsonObject:
     * @return com.blq.common.utils.ResultMsg
     * @Author: Blq
     * @Date: 2022/7/14 10:59
     */
    @PostMapping("WxPhone")
    public ResultMsg wxPhone(@RequestBody JSONObject jsonObject) {
        return apiService.wxPhone(jsonObject);
    }

    /**
     * @Description: 小程序用户注册
     * @Author: Blq <br>
     * @Date: 2022/8/26 0026 11:54
     * @Param: jsonObject
     * @Return: com.blq.common.utils.ResultMsg
     **/
    @PostMapping("UsetEnroll")
    public ResultMsg userEnroll(@RequestBody JSONObject jsonObject) {
        return apiService.addUser(jsonObject);
    }

    /**
     * APP绑定微信账户
     * @param jsonObject
     * @return
     */
    @PostMapping("wxAppAuth")
    public ResultMsg wxAppAuth(@RequestBody JSONObject jsonObject) {
        return apiService.wxAppAuth(jsonObject);
    }

    /**
     * 微信小程序授权获取openid
     * @param jsonObject
     * @return
     */
    @PostMapping("xcxAuth")
    public ResultMsg xcxAuth(@RequestBody JSONObject jsonObject) {
        return apiService.xcxAuth(jsonObject);
    }

    /**
     * 微信小程序授权登录
     * @param jsonObject
     * @return
     */
    @PostMapping("xcxLogin")
    public ResultMsg xcxLogin(@RequestBody JSONObject jsonObject) {
        return apiService.xcxLogin(jsonObject);
    }

    /**
     * 微信小程序授权获取手机号注册并登录
     * @param jsonObject
     * @return
     */
    @PostMapping("xcxRegister")
    public ResultMsg xcxRegister(@RequestBody JSONObject jsonObject) {
        return apiService.xcxRegister(jsonObject);
    }

    /**
     * @Description: 发送验证码
     * @Author: Blq <br>
     * @Date: 2022/8/26 0026 13:52
     * @Param: jsonObject
     * @Return: com.blq.common.utils.ResultMsg
     **/
    @PostMapping("SendMEssage")
    public ResultMsg sendMessage(@RequestBody JSONObject jsonObject) {
        return apiService.senndMessage(jsonObject);
    }

    /**
     * @Description: 用户登录
     * @Author: Blq <br>
     * @Date: 2022/8/26 0026 14:02
     * @Param: jsonObject
     * @Return: com.blq.common.utils.ResultMsg
     **/
    @PostMapping("UserLogin")
    public ResultMsg userLogin(@RequestBody JSONObject jsonObject) {
//        return apiService.userLogin(jsonObject);
        String userName = jsonObject.getString("userName");
        if (StringUtils.isBlank(userName)) return ResultMsg.ARGS_ERROR.setNewErrorMsg("用户手机号不能为空");
        String password = jsonObject.getString("userPassword");
        if (StringUtils.isBlank(password)) return ResultMsg.ARGS_ERROR.setNewErrorMsg("用户密码不能为空");
        // 生成令牌
        String token = loginService.appLogin(userName, password);
        JSONObject info = apiService.getUserInfo(userName);
        info.put("token", token);
        return ResultMsg.SELECT_SUCCESS.setNewData(info);
    }


    /**
     * @Description 接口描述 : 转单接口--把订单转移到订单池
     * @Params * @param null
     * customer_key : 订单id
     * loginmanId  : 当前登录人id
     * @Return
     * @Author xiaw
     * @Date 2022/12/25 0:15
     */
    @PostMapping("transfer")
    public ResultMsg transfer(@RequestBody JSONObject jsonObject) {
        return apiService.transfer(jsonObject);
    }

    /**
     * @Description: 新增订单申请信息
     * @Author: Blq <br>
     * @Date: 2022/8/30 0030 9:07
     * @Param: jsonObject
     * @Return: com.blq.common.utils.ResultMsg
     **/
    @PostMapping("AddCustomerRepair")
    public ResultMsg addCustomerRepair(@RequestBody JSONObject jsonObject) {
        return apiService.addCustomerRepair(jsonObject);
    }


    /**
     * @Description 接口描述 : 订单池展示接口
     * @Params * @param null
     * @Return
     * @Author xiaw
     * @Date 2022/12/25 0:04
     */
    @GetMapping("/orderPoollistOld")
    public ResultMsg orderPoollist() {
        return apiService.orderPoollist();
    }

    //    @GetMapping("/pageOrderList")
    @GetMapping("/orderPoollist")
    public ResultMsg pageOrderList(CustomerRepair customerRepair, PageQuery pageQuery) {
        List<CustomerRepair> customerRepairs = customerRepairService.selectByCustomerRepair(customerRepair, pageQuery);
        if (customerRepairs.size() == 0) {
            return ResultMsg.SUCCESS.setNewErrorMsg("暂时没有您的相关订单");
        } else {
            return ResultMsg.SELECT_SUCCESS.setNewData(customerRepairs);
        }
    }

    /*@GetMapping("/pageQueryOrder")
    public TableDataInfo<CustomerRepair> pageQueryOrder(CustomerRepair customerRepair, PageQuery pageQuery) {
        return apiService.orderPoollist();
    }*/

    /**
     * @Description 接口描述 : 小程序端获取我发布的待接单
     * @Params * @param null
     * status: "0"                        状态id
     * userId: "1023995635902185472"      用户id
     * 个人中心查看订单接口 : 待接单 :0/已接单 :21/待审核 : 8/待勘察 :9/待报价 :1/签单 :/待施工 :3/待验收 :4/待付款 :5/财务确认 :11/已付款 :10/已完成 :7/已关闭 :7/
     * @Return
     * @Author xiaw
     * @Date 2022/12/25 17:28
     */
    @PostMapping("GetMyCustomerRepair")
    public ResultMsg getMyCustomerRepair(@RequestBody JSONObject jsonObject) {
//        return apiService.getMyCustomerRepair(jsonObject);
        List<CustomerRepair> customerRepairs = customerRepairService.viewAllUserOrders(jsonObject);
        if (customerRepairs.size() == 0) {
            return ResultMsg.SUCCESS.setNewErrorMsg("暂时没有您的相关订单");
        } else {
            return ResultMsg.SELECT_SUCCESS.setNewData(customerRepairs);
        }
    }

    /**
     * @Description 接口描述 : 员工关闭工单接口
     * 传入
     * 用户id
     * 订单id
     * styleOrMannerOfWriting : 是否是通过产权异常过来的工单关闭单 :    是   : 1
     * @Params * @param null
     * @Return
     * @Author xiaw
     * @Date 2022/12/26 9:39
     */
    @PostMapping("close")
    public ResultMsg close(@RequestBody JSONObject jsonObject) {
        return apiService.close(jsonObject);
    }

    /**
     * @Description 获取用户信息
     * @Author Blq <Br />
     * @Date 8:51 2022/9/5
     * @Param jsonObject
     * @Return com.blq.common.utils.ResultMsg
     **/
    @PostMapping("GetUserInfo")
    public ResultMsg getUserInfo(@RequestBody JSONObject jsonObject) {
        return apiService.getUserInfoById(jsonObject);
    }

    /**
     * @Description 更新用户信息
     * @Author Blq <Br />
     * @Date 9:05 2022/9/5
     * @Param jsonObject
     * @Return com.blq.common.utils.ResultMsg
     **/
    @PostMapping("UpdateUser")
    public ResultMsg updateUser(@RequestBody JSONObject jsonObject) {
        return apiService.updateUser(jsonObject);
    }

    /**
     * @Description 更新用户手机号
     * @Author Blq <Br />
     * @Date 9:24 2022/9/5
     * @Param jsonObject
     * @Return com.blq.common.utils.ResultMsg
     **/
    @PostMapping("UpdateUserPhone")
    public ResultMsg updateUserPhone(@RequestBody JSONObject jsonObject) {
        return apiService.updateUserPhone(jsonObject);
    }

    /**
     * @Description 更新用户密码
     * @Author Blq <Br />
     * @Date 9:31 2022/9/5
     * @Param jsonObject
     * @Return com.blq.common.utils.ResultMsg
     **/
    @PostMapping("UpdatePassword")
    public ResultMsg updatePassword(@RequestBody JSONObject jsonObject) {
        return apiService.updatePassword(jsonObject);
    }

    /**
     * @Description 文件上传
     * @Author Blq <Br />
     * @Date 9:36 2022/9/5
     * @Param file
     * @Return com.blq.common.utils.ResultMsg
     **/
    @PostMapping("FilesUpload")
    public ResultMsg filesUpload(@RequestPart("file") MultipartFile file, String notesName) {
        return apiService.sendOss(file, notesName);
    }

    /**
     * @Description 商户注册
     * @Author Blq <Br />
     * @Date 8:48 2022/9/6
     * @Param jsonObject
     * @Return com.blq.common.utils.ResultMsg
     **/
    @PostMapping("MerchantRegistration")
    public ResultMsg merchantRegistration(@RequestBody JSONObject jsonObject) {
        return apiService.merchantRegistration(jsonObject);
    }

    /**
     * @Description 接口描述 : 商家app软件登录接口
     * @Params * @param null
     * userName : 用户手机号
     * userPassword: 用户密码
     * @Return
     * @Author xiaw
     * @Date 2022/12/25 0:02
     */
    @PostMapping("MerchantLogin")
    public ResultMsg merchantLogin(@RequestBody JSONObject jsonObject) {
//        return apiService.merchantLogin(jsonObject);
        String userName = jsonObject.getString("userName");
        if (StringUtils.isBlank(userName)) return ResultMsg.ARGS_ERROR.setNewErrorMsg("用户手机号不能为空");
        String password = jsonObject.getString("userPassword");
        if (StringUtils.isBlank(password)) return ResultMsg.ARGS_ERROR.setNewErrorMsg("用户密码不能为空");
        SysUser sysUser = sysUserService.selectUserByUserName(userName);
//        SysUser sysUser = sysUserService.selectUserById(info.getLong("userId"));
        if (sysUser != null && sysUser.getDeptId() != null && sysUser.getDeptId() == 1613808083627782145L) {
            return ResultMsg.OBJECT_ERROR.setNewErrorMsg("暂不支持平台客户登录app");
        }
        // 生成令牌
        String token = loginService.appLogin(userName, password);
        JSONObject info = apiService.getUserInfo(userName);
        info.put("token", token);
        return ResultMsg.SELECT_SUCCESS.setNewData(info);
    }

    /**
     * @Description 获取我的订单
     * @Author Blq <Br />
     * @Date 9:14 2022/9/6
     * @Param jsonObject
     * @Return com.blq.common.utils.ResultMsg
     * //需要传入用户id
     **/
    @PostMapping("MyTickets")
    public ResultMsg myTickets(@RequestBody JSONObject jsonObject) {
        return apiService.myTickets(jsonObject);
    }


    /**
     * @Description 接口描述 : 查看我的待办理订单
     * @Params * @param null
     * loginmanId :1023995635902185472----登录人的id
     * @Return
     * @Author xiaw
     * @Date 2022/12/24 23:58
     */
    @PostMapping("TicketPool")
    public ResultMsg ticketPool(@RequestBody JSONObject jsonObject) {
        ResultMsg resultMsg = apiService.ticketPool(jsonObject);
        return resultMsg;
    }

    /**
     * 查询待办理的工单
     * @param jsonObject
     * @return
     */
    @PostMapping("TicketPoolNew")
    public ResultMsg ticketPoolNew(@RequestBody JSONObject jsonObject) {
//        customerRepair.setCustomerFlag("0");
        List<CustomerRepair> customerRepairs = customerRepairService.queryPendingOrder(jsonObject);
        if (customerRepairs.size() == 0) {
            return ResultMsg.SUCCESS.setNewErrorMsg("暂时没有您的相关订单");
        } else {
            return ResultMsg.SELECT_SUCCESS.setNewData(customerRepairs);
        }
    }

    /**
     * @Description 获取全部单位
     * @Author Blq <Br />
     * @Date 10:59 2022/9/6
     * @Return com.blq.common.utils.ResultMsg
     **/
    @PostMapping("AllDepts")
    public ResultMsg getAllDepts(@RequestBody JSONObject jsonObject) {
        return apiService.getDepts(jsonObject);
    }

    @GetMapping("getDept")
    public ResultMsg getDept(@RequestParam String deptId) {
        return apiService.getDept(deptId);
    }

    /**
     * @Description 获取部门下成员信息
     * @Author Blq <Br />
     * @Date 11:09 2022/9/6
     * @Param jsonObject
     * @Return com.blq.common.utils.ResultMsg
     **/
    @PostMapping("GetDeptUser")
    public ResultMsg getDeptUser(@RequestBody JSONObject jsonObject) {
        return apiService.getDeptUser(jsonObject);
    }

    /**
     * @Description 接口描述 : 师傅端个人中心-查看待接单按钮
     * @Params * @param
     * status :
     * 个人中心查看订单接口 : 待接单 :0/已接单 :21/待审核 : 8/待勘察 :9/待报价 :1/签单 :/待施工 :3/待验收 :4/待付款 :5/财务确认 :11/已付款 :10/已完成 :7/已关闭 :7/
     * @Return
     * @Author xiaw
     * @Date 2022/12/25 0:06//万能查看订单接口/待审核,待勘察,其他状态
     */
    @PostMapping("MyGetTicketsOld")
    public ResultMsg myGetTickets(@RequestBody JSONObject jsonObject) {
        ResultMsg resultMsg = apiService.myTicketsMy(jsonObject);
        return resultMsg;
    }

    @PostMapping("MyGetTickets")
    public ResultMsg myGetTicketsNew(@RequestBody JSONObject jsonObject) {
        List<CustomerRepair> customerRepairs = customerRepairService.queryByUserIdAndStatus(jsonObject);
        if (customerRepairs.size() == 0) {
            return ResultMsg.SUCCESS.setNewErrorMsg("暂时没有您的相关订单");
        } else {
            return ResultMsg.SELECT_SUCCESS.setNewData(customerRepairs);
        }
    }

    /**
     * @Description 工单池抢单接口----需要工人id和订单id
     * @Author Blq <Br />
     * @Date 10:33 2022/9/7
     * @Param jsonObject
     * @Return com.blq.common.utils.ResultMsg
     **/
    @PostMapping("snatchOrders")
    public ResultMsg snatchOrders(@RequestBody JSONObject jsonObject) {
        return apiService.snatchOrders(jsonObject);
    }


    /**
     * @Description 审核接单请求
     * @Author Blq <Br />
     * @Date 10:46 2022/9/7
     * @Param jsonObject
     * @Return com.blq.common.utils.ResultMsg
     **/
    @PostMapping("ApproveRequest")
    public ResultMsg approveRequest(@RequestBody JSONObject jsonObject) {
        return apiService.approveRequest(jsonObject);
    }


    /**
     * @Description 接口描述 :  勘察资料提交接口
     * "investigationContent": "1223333333",
     * "investigationImages": "http://yongdianyi.oss-accelerate.aliyuncs.com/2022/12/26/e6fc8c02e1ad468bac4b61e3b900bfd5.jpeg,http://yongdianyi.oss-accelerate.aliyuncs.com/2022/12/26/9a9d2904944949f0833544fe6d638e3f.jpeg",
     * "investigationOver": "2022-12-26 15:50:12",
     * "investigationProperty": 1,   用户产权
     * "investigationRepari": "订单id",
     * "investigationTime": "2022-12-26 15:50:10"
     * @Params * @param null
     * @Return
     * @Author xiaw
     * @Date 2022/12/26 15:55
     */
    @PostMapping("AddInvestigation")
    public ResultMsg addInvestigation(@RequestBody JSONObject jsonObject) {
        return apiService.addInvestigation(jsonObject);
    }


    /**
     * @Description 接口描述 : 获取工单每步详情
     * @Params * @param null
     * @Return
     * @Author xiaw
     * @Date 2022/12/26 9:31
     */
    @PostMapping("GetTicketRow")
    public ResultMsg getTicketRow(@RequestBody JSONObject jsonObject) {
        return apiService.getTicketRow(jsonObject);
    }

    /**
     * @Description 新增报价单
     * @Author Blq <Br />
     * @Date 8:44 2022/9/13
     * @Param jsonObject
     * @Return com.blq.common.utils.ResultMsg
     **/
    @PostMapping("AddAuotation")
    public ResultMsg addAuotation(@RequestBody JSONObject jsonObject) {
        return apiService.addAuotation(jsonObject);
    }

    /**
     * @Description 商家端确认到账按钮
     * @Author Blq <Br />
     * @Date 9:53 2022/9/13
     * @Param jsonObject
     * @Return com.blq.common.utils.ResultMsg
     **/
    @PostMapping("ConfirmationOfReceipt")
    public ResultMsg confirmationOfReceipt(@RequestBody JSONObject jsonObject) {
        return apiService.confirmationOfReceipt(jsonObject);
    }


    /**
     * @Description 接口描述 : 施工材料上传
     * @Params * @param null
     * @Return
     * @Author xiaw
     * @Date 2022/12/26 17:05
     */
    @PostMapping("UploadMaterials")
    public ResultMsg uploadMaterials(@RequestBody JSONObject jsonObject) {
        return apiService.uploadMaterials(jsonObject);
    }

    /**
     * @Description 查询工单下资料信息
     * @Author Blq <Br />
     * @Date 9:25 2022/9/14
     * @Param jsonObject
     * @Return com.blq.common.utils.ResultMsg
     **/
    @PostMapping("SelectMaterials")
    public ResultMsg selectMaterials(@RequestBody JSONObject jsonObject) {
        return apiService.selectMaterials(jsonObject);
    }

    /**
     * @Description 小程序 新增评价信息----验收按钮
     * @Author Blq <Br />
     * @Date 9:46 2022/9/14
     * @Param jsonObject
     * @Return com.blq.common.utils.ResultMsg
     **/
    @PostMapping("AddEvaluation")
    public ResultMsg addEvaluation(@RequestBody JSONObject jsonObject) {
        return apiService.addEvaluation(jsonObject);
    }



    /**
     * @Description 最终财务确认到账
     * @Author Blq <Br />
     * @Date 10:03 2022/9/14
     * @Param jsonObject
     * @Return com.blq.common.utils.ResultMsg
     **/
    @PostMapping("FinalFinancialConfirmation")
    public ResultMsg finalFinancialConfirmation(@RequestBody JSONObject jsonObject) {


        return apiService.finalFinancialConfirmation(jsonObject);
    }

    /**
     * @Description 忘记密码
     * @Author Blq <Br />
     * @Date 10:43 2022/9/17
     * @Param jsonObject
     * @Return com.blq.common.utils.ResultMsg
     **/
    @PostMapping("ForgetPassword")
    public ResultMsg forgetPassword(@RequestBody JSONObject jsonObject) {
        return apiService.forgetPassword(jsonObject);
    }

    /**
     * @Description 接口描述 : 新增审核资料
     * @Params * @param null
     * "ticketCircumstance": "作业基本情况",
     * "ticketDept": 103,
     * "ticketRepair": "1055888104541388800",----工单id
     * "ticketReviewer": "1023995635902185472",   ----审核人 -当前登录人id
     * "ticketTime": "2022-12-24 13:00:00",
     * "ticketUser": "1023995635902185472",        人员信息
     * "ticketEquip": "装备情款",
     * "ticketCar": "交通情况"
     * @Return
     * @Author xiaw
     * @Date 2022/12/25 0:34
     */
    @PostMapping("TicketReview")
    public ResultMsg ticketReview(@RequestBody JSONObject jsonObject) {
        return apiService.ticketReview(jsonObject);
    }

    /**
     * @Description 获取全部公司信息
     * @Author Blq <Br />
     * @Date 14:28 2022/10/14
     * @Return com.blq.common.utils.ResultMsg
     **/
    @GetMapping("AllFrim")
    public ResultMsg frim(JSONObject jsonObject) {
        return apiService.firm(jsonObject);
    }

    /**
     * @Description 修改派单信息
     * @Author Blq <Br />
     * @Date 14:58 2022/10/14
     * @Param jsonObject
     * @Return com.blq.common.utils.ResultMsg
     **/
    @PostMapping("EditCuotomer")
    public ResultMsg editCuotomer(@RequestBody JSONObject jsonObject) {
        return apiService.editCuotomer(jsonObject);
    }


    @GetMapping("UserInfoSys")
    public ResultMsg userInfoSys(String customerKey) {
        return apiService.userInfoSys(customerKey);
    }

    /**
     * @description: 获取订单付款信息
     * @author: Bu Ling Qiang
     * @date: 2022/11/7 11:19
     * @param: id
     * @return: com.blq.common.utils.ResultMsg
     */
    @GetMapping("Finance")
    public R finance(String id) {
        return apiService.finance(id);
    }

    /**
     * @description: 获取业务分类
     * @author: Bu Ling Qiang
     * @date: 2022/11/7 11:19
     * @param:
     * @return: com.blq.common.utils.ResultMsg
     */
    @GetMapping("ServeClassify")
    public ResultMsg serveClassify() {
        return apiService.serveClassify();
    }

    /**
     * @Descriptio 搜索框高级查询
     * 根据用户的手机号和用户名进行模糊查询
     * userphone ; 用户手机号
     * username ; 用户名
     * @Author Blq <Br />
     * @Date 14:58 2022/10/14
     * @Param jsonObject
     * @Return com.blq.common.utils.ResultMsg
     **/
    @PostMapping("advancedQuery")
    public ResultMsg advancedQuery(@RequestBody JSONObject jsonObject) {
        return apiService.advancedQuery(jsonObject);
    }

    /**
     * @Description 接口描述 : 指派订单接口
     * "customerKey": "1056929541244583936",
     * "loginmanId": "1023995635902185472",
     * 指派人员id :
     * customerPlayer : 指派工人的id--指派给谁
     * "orderStatus": "1"
     * @Params * @param null
     * @Return
     * @Author xiaw
     * @Date 2022/12/28 17:05
     */
    @PostMapping("designate")
    public ResultMsg designate(@RequestBody JSONObject jsonObject) {
        return apiService.designate(jsonObject);
    }

    /**
     * @Description 接口描述 : 各种提交按钮
     * @Params * @param null
     * @Return
     * @Author xiaw
     * @Date 2022/12/30 11:14
     */
    @Transactional
    @PostMapping("submit")
    public ResultMsg submit(@RequestBody JSONObject jsonObject) {
        return apiService.submit(jsonObject);
    }

    /**
     * @Description 接口描述 : 客户签单接口
     * @Params * @param quotation_scmor合同/quotation_price价格
     * @Return
     * @Author xiaw
     * @Date 2023/1/2 17:41
     */
    @PostMapping("SignCcontract")
    public ResultMsg SignCcontract(@RequestBody JSONObject jsonObject) {
        return apiService.SignCcontract(jsonObject);
    }

    /**
     * 修改合同和报价信息
     * @param jsonObject
     * @return
     */
    @PostMapping("updateQuotation")
    public ResultMsg updateQuotation(@RequestBody JSONObject jsonObject) {
        return apiService.updateQuotation(jsonObject);
    }

    /**
     * 客户通过微信付款(生成微信付款订单信息给前端)
     * @param jsonObject
     * @return
     */
    @RepeatSubmit()
    @PostMapping("userPaymentOrder")
    public ResultMsg userPaymentOrder(@RequestBody JSONObject jsonObject) {
        return apiService.userPaymentOrder(jsonObject);
    }

    /**
     * @Description 接口描述 : 客户提交付款信息
     * @Params * @param quotation_scmor合同/quotation_price价格
     * @Return
     * @Author xiaw
     * @Date 2023/1/2 17:41
     */
    @PostMapping("userSubmitPayment")
    public ResultMsg userSubmitPayment(@RequestBody JSONObject jsonObject) {
        return apiService.userSubmitPayment(jsonObject);
    }

    /**
     * @Description 接口描述 :  公告接口
     * @Params * @param null 传入用户id
     * @Return
     * @Author xiaw
     * @Date 2023/1/2 22:01
     */
    @PostMapping("information")
    public ResultMsg find(@RequestBody JSONObject jsonObject) {
        return apiService.find(jsonObject);
    }

    /**
     * @Description 接口描述 : 客服确认到账接口
     * @Params * @param null
     * @Return
     * @Author xiaw
     * @Date 2023/1/3 9:50
     */
    @PostMapping("acknowledgement")
    public ResultMsg acknowledgement(@RequestBody JSONObject jsonObject) {
        return apiService.acknowledgement(jsonObject);
    }

    /**
     * @Description 接口描述 : 查看用户的所有订单
     * @Params  * @param null
     * @Return
     * @Author xiaw
     * @Date 2023/1/6 15:44
     *
     */
    @PostMapping("viewAllUserOrders")
    public ResultMsg viewAllUserOrders(@RequestBody JSONObject jsonObject) {
//        return apiService.viewAllUserOrders(jsonObject);
        List<CustomerRepair> customerRepairs = customerRepairService.viewAllUserOrders(jsonObject);
        if (customerRepairs.size() == 0) {
            return ResultMsg.SUCCESS.setNewErrorMsg("暂时没有您的相关订单");
        } else {
            return ResultMsg.SELECT_SUCCESS.setNewData(customerRepairs);
        }
    }

    /**
     * @Description 接口描述 : 查询所用用户
     * @Params  * @param null
     * @Return
     * @Author xiaw
     * @Date 2023/1/6 15:44
     */
    @PostMapping("queryUser")
    public ResultMsg queryUser() {
        return apiService.queryUser();
    }

    /**
     * @Description 接口描述 : 供电所查该供电所顶单--checkAnOrder
     * @Params  * @param null
     * @Return
     * @Author xiaw
     * @Date 2023/1/6 15:44
     */
    @PostMapping("checkAnOrder")
    public ResultMsg checkAnOrder(@RequestBody JSONObject jsonObject) {
        return apiService.checkAnOrder(jsonObject);
    }
    /**
     * @Description 接口描述 :查所有的财务人员
     * @Params  * @param null
     * @Return              传入一个 公司id
     * @Author xiaw
     * @Date 2023/1/6 15:44
     */
    @PostMapping("checkFinancialAffairs")
    public R checkFinancialAffairs(@RequestBody JSONObject jsonObject) {

        return apiService.checkFinancialAffairs(jsonObject);
    }

    /**
     * @Description 接口描述 :
     * @Params  * @param null
     * @Return 根据登陆人id查询各种工单状态的待处理数量（小程序和app）--需要一个接口   -----
     * @Author xiaw
     * @Date 2023/1/31 14:42
     */
    @PostMapping("queryVariousOrders")
    public R queryVariousOrders(@RequestBody JSONObject jsonObject) {

//        return apiService.queryVariousOrders(jsonObject);
        return R.ok(customerRepairService.queryVariousOrders(jsonObject));
    }

    /**
     * @Description 接口描述 : 判断是不是审核人员
     * @Params  * @param null
     * @Return
     * @Author xiaw
     * @Date 2023/1/31 14:42
     */
    @PostMapping("JudgeTheRole")
    public Boolean JudgeTheRole(@RequestBody JSONObject jsonObject) {

        return apiService.JudgeTheRole(jsonObject);
    }

///**
// * @Description 接口描述 : 微信三方登录
// * @Params  * @param null
// * @Return
// * @Author xiaw
// * @Date 2023/2/16 17:31
// */
//    @GetMapping("/weChat/{code}")
//    public ResultMsg account(@PathVariable ("code") String code){
//        try {
//            //service层.直接返回一个JsonResult
//            return apiService.weChat(code);
//        } catch (Exception e) {
//            e.printStackTrace();
//            return ResultMsg.ARGS_ERROR.setNewErrorMsg(e.getMessage());
//        }
//    }


}
